/**
 * 构造方法重载
 */
class runDemo{
    private String username,password;
    runDemo(){
        System.out.println("All is null!");
    }
    runDemo(String name){
        username = name;
    }
    runDemo(String name,String pwd){
        this(name); // 等同于 username = name; 因为this就是调用当前类的构造方法，然后传递的是name字符串，所以调用的是第二个构造函数，执行username=name这个过程
        password = pwd;
        check();
    }

    /**
     * 验证用户密码
     */
    void check(){
        String s = null;
        if(username != null) s = "当前用户名为："+username;
        else s += "\n用户名不能为空";
        if(password != "hello") s += "\n密码错误";
        else s += "\n 登录成功";

        System.out.println(s);
    }
}

public class override{
    public static void main(String[] args) {
        new runDemo();
        new runDemo("华仔");
        new runDemo("华仔","hello");
    }
}